﻿@using SailHero.Soft.FrameWork.Models;       
@{
    //ViewBag.Title = "模块管理";
    Layout = "../Shared/_Layout.cshtml";
}

<script type="text/javascript">
    $(function () {
        $("#chkAll").click(function () {
            var flag = $(this).attr("checked");
            if (flag == "checked") {
                $("[name=CheckBoxSelect]:checkbox").each(function () {
                    $(this).attr("checked", flag);
                });
            }
            else {
                $("[name=CheckBoxSelect]:checkbox").each(function () {
                    $(this).attr("checked", false);
                });

            }
        });

        $("[name=CheckBoxSelect]").click(function () {
            $("#chkAll").attr("checked", false);
        });

        $("#edit").click(function () {
            var obj = $("[name=CheckBoxSelect]:checked");
            if (obj.length == 0) {
                $.messager.alert("提示信息", "请选择编辑项！", "info");
            }
            else if (obj.size() > 1) {
                $.messager.alert("提示信息", "一次只能编辑一项！", "info");
            }
            else {
                obj.each(function () {
                    var value = $(this).val();
                    location.href = "/Model/Edit/?id=" + value;
                });
            }
        });

        $("#delete").click(function () {

            var obj = $("[name=CheckBoxSelect]:checked");
            if (obj.length == 0) {
                $.messager.alert("提示信息", "请选择删除项！", "info");
            }
            else if (obj.size() > 1) {
                $.messager.alert("提示信息", "一次只能删除一项！", "info");
            }
            else {
                var select = "";
                obj.each(function () {
                    select = $(this).val();
                });
                $.messager.confirm("提示信息", "确定要删除选中项？", function (r) {
                    if (r) {
                        var url = "/Model/Delete/?id=" + select;
                        $.post(url,
                function (data) {
                    if (data == "success") {
                        window.location.href = "/Model/Index";
                    }
                    else {
                        $.messager.alert("错误信息", data, "error");
                    }
                });
                    }
                });
            }
        });
    });
</script>

<table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
    <tr>
        <td>
            <table style="width: 100%; margin-top: 5px;" cellpadding="0" cellspacing="0">
                <caption class="tcaption">
                    <table style="width: 100%;" cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td align="left">
                                <table class="tableTitle">
                                    <tr>
                                        <td width="80px">
                                            <span style="color: Green; font-weight: bold; padding-left: 5px;">模块列表</span>
                                        </td>
                                        <td width="50px">
                                            <a href="/Model/Create" class="operateA">
                                                <img style="vertical-align: middle; border: 0;" src="@Href("../../content/images/add.png")"
                                                    alt="新增" />&nbsp;新增</a>
                                        </td>
                                        <td width="50px">
                                            <a id="edit">
                                                <img style="vertical-align: middle" src="@Href("../../content/images/edit2.png")" alt="修改" />&nbsp;编辑</a>
                                        </td>
                                        <td width="50px">
                                            <a id="delete">
                                                <img style="vertical-align: middle" src="@Href("../../content/images/delete.png")" alt="删除" />&nbsp;删除</a>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                    </table>
                </caption>
                <tr>
                    <td>
                        <div>
                            <table class="mytable" cellspacing="0" border="1" style="width: 100%; border-collapse: collapse;">
                                <tr>
                                    <th>
                                        NO.
                                    </th>
                                    <th>
                                        <input id="chkAll" type="checkbox" />
                                    </th>
                                    <th>
                                        模块名称
                                    </th>
                                    <th>
                                        URL
                                    </th>
                                    <th>
                                        上级模块
                                    </th>
                                    <th>
                                        排序号
                                    </th>
                                    <th>
                                        是否显示
                                    </th>
                                </tr>
                                @{
                                    int num = 0;
                                    foreach (var mod in Model)
                                    {
                                        num++;
                                    <tr>
                                        <td align="center" style="width: 30px;">
                                            @num
                                        </td>
                                        <td align="center" style="width: 30px;">
                                            <input id="CheckBoxSelect" name="CheckBoxSelect" value="@mod.ModelID" type="checkbox" />
                                        </td>
                                        <td align="center" style="width: 10%;">
                                            @mod.ModelCName
                                        </td>
                                        <td align="center">
                                            @mod.URL
                                        </td>
                                        <td align="center">
                                        
                                        </td>
                                        <td align="center">
                                            @mod.OrderNum
                                        </td>
                                        <td align="center">
                                            @if (mod.IsShow==1)
                                            {
                                                @:显示
                                        }
                                            else
                                            { <font color="red">不显示</font>}
                                        </td>
                                    </tr>
                                    }
                                }
                            </table>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="page2">
                        @Html.Raw(ViewBag.Page)
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
